package visiopuce.DAO;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import org.hibernate.ObjectNotFoundException;
import org.hibernate.Query;

import visiopuce.HibernateUtil;
import visiopuce.objets.VerifBiomol;

public class VerifBiomolDAOImpl extends GenericDAOImpl<VerifBiomol, BigDecimal> implements VerifBiomolDAO {

	/** Constructeur priv� */
	private VerifBiomolDAOImpl() {
	}

	/** Instance unique non pr�initialis�e */
	private static VerifBiomolDAOImpl INSTANCE = null;

	/** Point d'acc�s pour l'instance unique du singleton */
	public static VerifBiomolDAO getInstance() {
		if (INSTANCE == null) {
			INSTANCE = new VerifBiomolDAOImpl();
		}
		return INSTANCE;
	}

	@Override
	public List<VerifBiomol> getVerifBiomolByIdAlteration(int idAlt) {

		List<VerifBiomol> vb = new ArrayList<VerifBiomol>();
		try {
			String sql = "SELECT v FROM VerifBiomol v WHERE v.alteration.idAlteration = :idAlteration";
			Query query = HibernateUtil.getSession().createQuery(sql).setParameter("idAlteration", idAlt);
			vb = findMany(query);
		} catch (ObjectNotFoundException ex) {
			vb = new ArrayList<VerifBiomol>();
		}
		return vb;
	}

	@Override
	public List<VerifBiomol> getVerifBiomolByRenduBiomol(int idRenduBiomol) {
		List<VerifBiomol> vb = new ArrayList<VerifBiomol>();
		try {
			String sql = "SELECT v FROM VerifBiomol v WHERE v.renduBiomol.idRenduBioMol = :idRenduBiomol";
			Query query = HibernateUtil.getSession().createQuery(sql).setParameter("idRenduBiomol", idRenduBiomol);
			vb = findMany(query);
		} catch (ObjectNotFoundException ex) {
			vb = new ArrayList<VerifBiomol>();
		}
		return vb;
	}

}